#pragma once
#pragma warning(disable:4996)       // disable checked iterator errors http://msdn.microsoft.com/en-us/library/aa985965(VS.80).aspx 

//
// Copyright (C) 2011 - 2013 Steve Channell steve.channell@cepheis.com
//
// This file is part of Cephei.QL, an open-source library wrapper 
// arround QuantLib http://quantlib.org/
//
// Cephei.QL is open source software: you can redistribute it and/or modify it
// under the terms of the license.  You should have received a
// copy of the license along with this program; if not, please email
// <support@cepheis.com>. The license is also available online at
// <http://cepheis.com/license.htm>.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE.  See the license for more details.
//
// Version 2.2 with QuantLib 1.2.1

#include <Macros.h>
#include <ValueHelpers.h>
#include <Settings.h>

#include <gen/QL/StochasticProcess1D.h>
#pragma unmanaged 
#include <ql\experimental\variancegamma\variancegammaprocess.hpp>
#include <boost/smart_ptr/detail/spinlock.hpp>
#pragma managed 

using namespace System;
using namespace QuantLib;
using namespace Cephei;
using namespace Cephei::Core;
using namespace PLATFORM::Collections;

using namespace Cephei::QL::Termstructures;
using namespace Cephei::QL;
using namespace Cephei::QL::Math;
#define HANDLE
#undef ABSTRACT
#undef STRUCT
namespace Cephei { namespace QL { namespace Experimental { namespace Variancegamma {
	//////////////////////////////////////////////////////////////////////////////////////////////
	// implementation of IVarianceGammaProcess
	public ref class CVarianceGammaProcess  : 
            public CStochasticProcess1D,
            public Cephei::QL::Experimental::Variancegamma::IVarianceGammaProcess
	{
	protected: 
		boost::shared_ptr<QuantLib::VarianceGammaProcess>* _ppVarianceGammaProcess;
#ifdef HANDLE
		QuantLib::Handle<QuantLib::VarianceGammaProcess>* _phVarianceGammaProcess;
#endif
		Object^ _VarianceGammaProcessOwner;     // reference to object that manages the storage for this object
	internal:
		CVarianceGammaProcess (Cephei::QL::IQuote^ s0, Cephei::QL::Termstructures::IYieldTermStructure^ dividendYield, Cephei::QL::Termstructures::IYieldTermStructure^ riskFreeRate, Double sigma, Double nu, Double theta);
        CVarianceGammaProcess (boost::shared_ptr<QuantLib::VarianceGammaProcess>& childNative, Object^ owner);
        CVarianceGammaProcess (QuantLib::VarianceGammaProcess& childNative, Object^ owner);
        CVarianceGammaProcess (CVarianceGammaProcess^ copy);
        CVarianceGammaProcess (PLATFORM::Type^ t);
#ifdef STRUCT
        CVarianceGammaProcess (QuantLib::VarianceGammaProcess childNative);
#endif       
#ifdef HANDLE
		CVarianceGammaProcess (QuantLib::Handle<QuantLib::VarianceGammaProcess>& childNative, Object^ owner);
		CVarianceGammaProcess (QuantLib::Handle<QuantLib::VarianceGammaProcess> childNative);
#endif
		virtual ~CVarianceGammaProcess ();
		!CVarianceGammaProcess ();

	internal:
		QuantLib::VarianceGammaProcess& GetReference ();
		boost::shared_ptr<QuantLib::VarianceGammaProcess>& GetShared ();
		QuantLib::VarianceGammaProcess* GetPointer ();
        void SetVarianceGammaProcess (boost::shared_ptr<QuantLib::VarianceGammaProcess> native)
        {
            if (_ppVarianceGammaProcess != NULL)
                delete _ppVarianceGammaProcess;
            _ppVarianceGammaProcess = new boost::shared_ptr<QuantLib::VarianceGammaProcess> (native);
            SetStochasticProcess1D (boost::dynamic_pointer_cast<QuantLib::StochasticProcess1D> (*_ppVarianceGammaProcess));
        }
#ifdef HANDLE
		QuantLib::Handle<QuantLib::VarianceGammaProcess>& GetHandle ();
#endif
		virtual bool HasNative () override;
    public:
		virtual Double Diffusion (Double t, Double x) ;
        property Cephei::QL::Termstructures::IYieldTermStructure^ DividendYield 
        {
		    virtual Cephei::QL::Termstructures::IYieldTermStructure^ get () ;
        }
		virtual Double Drift (Double t, Double x) ;
        property Double Nu 
        {
		    virtual Double get () ;
        }
        property Cephei::QL::Termstructures::IYieldTermStructure^ RiskFreeRate 
        {
		    virtual Cephei::QL::Termstructures::IYieldTermStructure^ get () ;
        }
        property Cephei::QL::IQuote^ S0 
        {
		    virtual Cephei::QL::IQuote^ get () ;
        }
        property Double Sigma 
        {
		    virtual Double get () ;
        }
        property Double Theta 
        {
		    virtual Double get () ;
        }
        property Double X0 
        {
		    virtual Double get () ;
        }
    };
	//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	// Factory class
//z	[FactoryFor(Core::Generic::ICoCell<Cephei::QL::Experimental::Variancegamma::IVarianceGammaProcess^>::typeid)]
	[FactoryFor(Cephei::QL::Experimental::Variancegamma::IVarianceGammaProcess::typeid)]
	[FactoryFor(Cephei::QL::Experimental::Variancegamma::IVarianceGammaProcess_Factory::typeid)]
	public ref class CVarianceGammaProcess_Factory sealed : public IVarianceGammaProcess_Factory
	{
	public:
        virtual IVarianceGammaProcess^ Create (Cephei::QL::IQuote^ s0, Cephei::QL::Termstructures::IYieldTermStructure^ dividendYield, Cephei::QL::Termstructures::IYieldTermStructure^ riskFreeRate, Double sigma, Double nu, Double theta);
    };
   
/*Cephei*/ } /*QL*/ } /*Experimental*/ } /*Variancegamma */}
